<?php

require_once 'phpmoko/ui/Panel.php';

class DeckPanel extends Panel
{
	private $widgetShowed = -1;
	private $animationEnabled = false;

	function __construct()
	{
		parent::__construct();
	}

	function isAnimationEnabled()
	{
		return $this->animationEnabled;
	}

	function setAnimationEnabled($enable)
	{
		$this->animationEnabled = $enable;
	}

	function showWidget($index)
	{
		$this->widgetShowed = $index;
	}

	function toString()
	{
		$i = 0;
		$this->rewind();
		while ($this->valid())
		{
			$this->current()->setVisible($this->widgetShowed == $i);

			$i++;
			$this->next();
		}

		$str = '<div';

		if ($this->style != null)
			$str .= ' class="'.$this->style.'"';

		$str .= '>';
			
		$i = 0;
		foreach ($this as $widget)
		{
			$i++;
			$str .= '<div id="'.$this->id.'-'.$i.'" style="margin: 0px; padding: 0px; width: 100%;';
			if (!$widget->isVisible())
				$str .= ' display: none;';

			$str .= '">';


			$str .= $widget->toString();
			$str .= '</div>';
		}

		$str .= '</div>';

		$str .= '<script type="text/javascript"> $("#'.$this->id.'-TabBar").phpmokodeckpanel(';
		if ($this->animationEnabled)
			$str .= '{animated:true}';

		$str .= '); </script>';

		return $str;
	}
}
?>